﻿Imports System.Data.Objects

Class Application

  ' Application-level events, such as Startup, Exit, and DispatcherUnhandledException
  ' can be handled in this file.

  Private Sub Application_Exit(sender As Object, e As ExitEventArgs) Handles Me.Exit

    'DB.Context.SaveChanges()

    With DB.Context.ObjectStateManager
      If .GetObjectStateEntries(System.Data.EntityState.Deleted).Count > 0 Or .GetObjectStateEntries(System.Data.EntityState.Added).Count > 0 Then
        If MsgBox("Speichern?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
          DB.Context.SaveChanges()
        End If
      End If
    End With
  End Sub

  Private Sub Application_Startup(sender As Object, e As StartupEventArgs)
    Dim a As New MainWindow
    a.ShowDialog()
  End Sub
End Class
